package com.ctshk.rpc.season.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.season.dto.SeasonProductStrategyDTO;
import com.ctshk.rpc.season.entity.SeasonProductStrategy;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;


/**
 * <p>
 * 套票产品成本策略表 Mapper 接口
 * </p>
 *
 * @author 杨林
 * @since 2021-03-15
 */
public interface SeasonProductStrategyMapper extends BaseMapper<SeasonProductStrategy> {


    //根据产品id 获取 和日期获取 固定套票 策略信息
    @Select("<script>" +
            " select t.id,t.cost_name,t.season_product_id as productid from t_season_product_strategy t" +
            " left join t_season_product_strategy_vaild_date td on t.id=td.strategy_id" +
            " where t.is_deleted = 0 and td.is_deleted=0" +
            " <if test=\"productId != null and productId != ''\"> AND t.season_product_id = #{productId}</if> " +
            " <if test=\"date != null \"> AND  #{date}  between td.time_begin and td.time_end</if> " +
            " </script>")
    SeasonProductStrategyDTO querySaleStrategy(@Param("productId") Long productId, @Param("date") LocalDate date);


    //根据产品id  和日期获取 固定套票 策略信息
    @Select("select t.id from t_season_product_strategy t where t.season_product_id =#{productId}")
    List<Long> queryStrategyByProductId(@Param("productId") Long productId);
}
